<div>
    <el-row :gutter="20">
        <el-col :span="5">
            <el-button type="primary" v-if="needAdminRole" @click="openFormWin">新建生活号</el-button>
        </el-col>
     <!--    <el-col :span="3">
            <el-button type="primary" v-if="needAdminRole" @click="showCopy=true">复制生活号</el-button>
        </el-col> -->

        <el-col :span="15">
            商户号  :
            <el-select filterable v-model="searchMerchants"  placeholder="请选择">
                    <el-option v-for="merchant in merchants" :key="merchant.value" :label="merchant.label" :value="merchant.value">
                    </el-option>
                </el-select>
            生活号筛选：
            <el-select filterable v-model="srchLifeIds" multiple placeholder="请选择">
                <el-option v-for="life in allLifes" :key="life.id" :label="life.name" :value="life.id">
                </el-option>
            </el-select>
            名称：
            <el-input style="width: 150px" placeholder="生活号名称" v-model="pageInfo.srch_LIKE_name" autocomplete="off">
            </el-input>
            <el-button type="primary" @click="initData">搜索 </el-button>
        </el-col>
    </el-row>
    <el-row>
        <el-table :data="tableData" stripe border style="width: 100%;margin-top: 10px">
            <el-table-column prop="akjMerchants.pidName" show-overflow-tooltip="true" label="商户号">
            </el-table-column>
            <el-table-column prop="lifeId" label="生活号ID">
                <template slot-scope="scope">
                    <el-link type="primary" @click="openDetail(scope.row) ">{{scope.row.lifeId}}</el-link>
                </template>
            </el-table-column>
            <el-table-column prop="name" label="生活号名称">
            </el-table-column>
            <el-table-column prop="privteKey" show-overflow-tooltip="true" label="应用私钥">
            </el-table-column>
            <el-table-column prop="publicKey" show-overflow-tooltip="true" label="应用公钥">
            </el-table-column>
            <el-table-column show-overflow-tooltip="true" prop="alipayPublicKey" label="支付宝公钥">
            </el-table-column>
            <el-table-column show-overflow-tooltip="true" prop="aesKey" label="AES秘钥">
            </el-table-column>
            <el-table-column prop="tel" label="联系电话">
            </el-table-column>
            <el-table-column prop="createBy.name" label="创建人">
            </el-table-column>
            <el-table-column prop="createAt" label="创建时间">
            </el-table-column>
            <el-table-column label="操作" width="150">
                <template slot-scope="scope">
                    <el-button @click="updateLife(scope.row)" v-if="needAdminRole && !scope.row.delete" type="text"
                        size="small">编辑</el-button>
                    <el-button @click="openCopy(scope.row)" v-if="needAdminRole && !scope.row.delete" type="text"
                        size="small">复制</el-button>
                    <el-button v-if="needAliMgrRole && scope.row.delete" type="text" size="small">已停用</el-button>
                    <el-button @click="deleteLife(scope.row)" v-if="needAdminRole && !scope.row.delete" type="text"
                        size="small">停用</el-button>
                    <el-button @click="enableLife(scope.row)" v-if="needAdminRole && scope.row.delete && !scope.row.akjMerchants.delete" type="text"
                        size="small">启用</el-button>
                </template>
            </el-table-column>
        </el-table>
    </el-row>
    <div class="marginT10 center">
        <el-pagination background layout="prev, pager, next" @current-change="handleCurrentChange"
            :page-size="pageInfo.pageSize" :total="pageInfo.totalNum">
        </el-pagination>
    </div>
    <el-dialog title="新建生活号" :visible.sync="dialogFormVisible" width="45%">
        <el-form :model="form">
        <el-form-item class="label" label="商户号" :label-width="formLabelWidth">
                <el-col>
                    <el-select  style="width:300px"  v-model="form.akjMerchants.id" placeholder="商户号" >
                        <el-option :label="item.label" v-for="(item,index) in merchants"
                            :value="item.value"></el-option>
                    </el-select>
                </el-col>
            </el-form-item>
            <el-form-item label="生活号ID：" :label-width="formLabelWidth">
                <el-input v-model="form.lifeId" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="生活号名称：" :label-width="formLabelWidth">
                <el-input v-model="form.name" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="应用私钥：" :label-width="formLabelWidth">
                <el-input v-model="form.privteKey" type="textarea" :rows="3" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="应用公钥：" :label-width="formLabelWidth">
                <el-input type="textarea" :rows="3" v-model="form.publicKey" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="AES秘钥：" :label-width="formLabelWidth">
                <el-input type="textarea" :rows="3" v-model="form.aesKey" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="支付宝公钥：" :label-width="formLabelWidth">
                <el-input type="textarea" :rows="3" v-model="form.alipayPublicKey" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="联系电话：" :label-width="formLabelWidth">
                <el-input v-model="form.tel" autocomplete="off"></el-input>
            </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
            <el-button @click="dialogFormVisible = false">取 消</el-button>
            <el-button type="primary" @click="submitForm">确 定</el-button>
        </div>
    </el-dialog>

    <el-dialog title="复制生活号" :visible.sync="showCopy" width="30%">
        <el-form :model="copyForm">
            <!--            <el-form-item label="生活号ID：" :label-width="formLabelWidth">-->
            <!--                <el-input v-model="form.lifeId" autocomplete="off"></el-input>-->
            <!--            </el-form-item>-->
            <el-form-item label="生活号名称：" :label-width="formLabelWidth">
                <el-input v-model="copyForm.name" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="联系电话：" :label-width="formLabelWidth">
                <el-input v-model="copyForm.tel" autocomplete="off"></el-input>
            </el-form-item>

            <el-form-item label="生活号：" :label-width="formLabelWidth">
                <el-select v-model="copyForm.copyFrom" placeholder="生活号" style="width:100%" disabled="true">
                    <el-option>请选择</el-option>
                    <el-option v-for="life in allLifes" :key="life.id" :label="life.name" :value="life.id">
                    </el-option>
                </el-select>
            </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
            <el-button @click="showCopy = false">取 消</el-button>
            <el-button type="primary" @click="submitCopyForm">确 定</el-button>
        </div>
    </el-dialog>

    <el-dialog title="编辑生活号" :visible.sync="showEditWin" width="45%">
        <el-form :model="editForm">
        <el-form-item class="label" label="商户号：" :label-width="formLabelWidth">
            <el-select style="width:300px" v-model="editForm.akjMerchants.id" placeholder="商户号">
                <el-option :label="item.label" v-for="(item,index) in merchants"
                    :value="item.value"></el-option>
            </el-select>
            </el-form-item>
            <el-form-item label="生活号ID：" :label-width="formLabelWidth">
                <el-input v-model="editForm.lifeId" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="生活号名称：" :label-width="formLabelWidth">
                <el-input v-model="editForm.name" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="应用私钥：" :label-width="formLabelWidth">
                <el-input v-model="editForm.privteKey" type="textarea" :rows="3" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="应用公钥：" :label-width="formLabelWidth">
                <el-input type="textarea" :rows="3" v-model="editForm.publicKey" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="AES秘钥：" :label-width="formLabelWidth">
                <el-input type="textarea" :rows="3" v-model="editForm.aesKey" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="支付宝公钥：" :label-width="formLabelWidth">
                <el-input type="textarea" :rows="3" v-model="editForm.alipayPublicKey" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="联系电话：" :label-width="formLabelWidth">
                <el-input v-model="editForm.tel" autocomplete="off"></el-input>
            </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
            <el-button @click="cancelEdit">取 消</el-button>
            <el-button type="primary" @click="submitEditForm">确 定</el-button>
        </div>
    </el-dialog>

    <el-dialog title="生活号详情" :visible.sync="showDetails" width="45%">
        <el-form :model="detailData">
            <el-form-item label="商户号：" :label-width="formLabelWidth">
                    <span>{{detailData.akjMerchants?detailData.akjMerchants.pidName:""}}</span>
                </el-form-item>
            <el-form-item label="生活号ID：" :label-width="formLabelWidth">
                <span>{{detailData.lifeId}}</span>
            </el-form-item>
            <el-form-item label="生活号名称：" :label-width="formLabelWidth">
                <span>{{detailData.name}}</span>
            </el-form-item>
            <el-form-item label="创建人：" :label-width="formLabelWidth">
                <span>{{detailData.createBy.name}}</span>
            </el-form-item>
            <el-form-item label="创建时间：" :label-width="formLabelWidth">
                <span>{{detailData.createAt}}</span>
            </el-form-item>
            <el-form-item label="联系电话：" :label-width="formLabelWidth">
                <span>{{detailData.tel}}</span>
            </el-form-item>
            <el-form-item label="应用公钥：" :label-width="formLabelWidth">
                <span>{{detailData.publicKey}}</span>
            </el-form-item>
            <el-form-item label="应用私钥：" :label-width="formLabelWidth">
                <span>{{detailData.privteKey}}</span>
            </el-form-item>
            <el-form-item label="支付宝公钥：" :label-width="formLabelWidth">
                <span>{{detailData.alipayPublicKey}}</span>
            </el-form-item>
            <el-form-item label="AES秘钥：" :label-width="formLabelWidth">
                <span>{{detailData.aesKey}}</span>
            </el-form-item>
        </el-form>
    </el-dialog>
</div>